package com.shijunhao.graduation.domain.bean;

import com.shijunhao.graduation.domain.entity.SystemFileInfo;

/**
 * @author: shijunhao
 * @date: 2022/4/19 0:31
 * @description:
 */
public class WangEditorResponse {
    private Integer errno;

    private String message;

    private Data data;

    public Integer getErrno() {
        return errno;
    }

    public void setErrno(Integer errno) {
        this.errno = errno;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    public static WangEditorResponse success(SystemFileInfo fileInfo){
        WangEditorResponse response = new WangEditorResponse();
        response.setErrno(0);
        Data data = new Data();
        data.setUrl("/api/file/download/"+fileInfo.getId());
        data.setAlt(fileInfo.getFileName());
        response.setData(data);
        return response;
    }

    public static WangEditorResponse error(String msg){
        WangEditorResponse response = new WangEditorResponse();
        response.setErrno(1);
        response.setMessage(msg);
        return response;
    }
}

class Data{
    private String url;
    private String alt;
    private String href;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAlt() {
        return alt;
    }

    public void setAlt(String alt) {
        this.alt = alt;
    }

    public String getHref() {
        return href;
    }

    public void setHref(String href) {
        this.href = href;
    }
}